package net.jarang.study.spring.web;

import net.jarang.study.spring.converter.Level;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.ConversionService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;


@Controller
public class ValidationController3 {
	@Autowired ConversionService conversionService;
	
	@RequestMapping("/level3")
	public ModelAndView level3(@RequestParam Level level) {
		ModelAndView mav = new ModelAndView("result");
		mav.addObject("result1", level);
		return mav;
	}
	
	@InitBinder
	public void initBinder(WebDataBinder dataBinder) {
		System.out.println("dataBinder : " + dataBinder.getConversionService());
		dataBinder.setConversionService(conversionService);
	}
}
